import request from "@/utils/request";

export const getQueryCourses = (data: any) => {
  return request({
    method: "POST",
    url: '/boss/course/getQueryCourses',
    data
  })
}

export const changeState = (params: any) => {
  return request({
    method: "GET",
    url: '/boss/course/changeState',
    params
  })
}

export const saveOrUpdateCourse = (data: any) => {
  return request({
    method: "POST",
    url: '/boss/course/saveOrUpdateCourse',
    data
  })
}

export const uploadCourseImage = (data: any, onUploadProgress?: (e: any) => void) => {
  // form-data
  return request({
    method: "POST",
    url: '/boss/course/upload',
    data,
    // h5 新增事件：progress
    onUploadProgress
  })
}

export const getCourseById = (courseId: string | number) => {
  return request({
    method: "GET",
    url: '/boss/course/getCourseById',
    params: {
      courseId
    }
  })
}

export const getSectionAndLesson = (courseId: string | number) => {
  return request({
    method: "GET",
    url: '/boss/course/section/getSectionAndLesson',
    params: {
      courseId
    }
  })
}

export const saveOrUpdateSection = (data: any) => {
  return request({
    method: "POST",
    url: '/boss/course/section/saveOrUpdateSection',
    // data: {
    //   sectionForm: data
    // }
    data
  })
}

export const getBySectionId = (sectionId: any) => {
  return request({
    method: "GET",
    url: '/boss/course/section/getBySectionId',
    params: {
      sectionId
    }
  })
}

export const saveOrUpdateLesson = (data: any) => {
  return request({
    method: "POST",
    url: '/boss/course/lesson/saveOrUpdate',
    data
  })
}

export const getByIdLesson = (lessonId: any) => {
  return request({
    method: "GET",
    url: '/boss/course/lesson/getById',
    params: {
      lessonId
    }
  })
}